import json
import os
from glob import glob
from pathlib import Path

from option import parse_args


def no_duplicate(root_dir):
    video_name_set = set()
    for json_path in glob(os.path.join(root_dir, "dfdc_train_part_*/metadata.json")):
        json_path_parent = Path(json_path).parent
        with open(json_path, "r") as f:
            metadata = json.load(f)
        for k, v in metadata.items():
            if k in video_name_set:
                print(os.path.join(json_path_parent, k))
            else:
                video_name_set.add(k)
    print(len(video_name_set))


def main():
    args = parse_args()
    no_duplicate(args.root_dir)


if __name__ == '__main__':
    main()
